package com.didispace;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;

// 创建 DiscoveryClient 接口针对 Eureka 客户端的 EurekaDiscoveryClient 实例）， 才能实现上述 Controller 中对服务信息的输出
@EnableHystrix
@EnableDiscoveryClient	// 激活 Eureka 中的 DiscoveryClient 实现（自动化配置，
@SpringBootApplication
public class UserApplication {

	public static void main(String[] args) {
		SpringApplication.run(UserApplication.class, args);
	}

}

// PS F:\BOOK\2022\Spring Cloud微服务实战\SpringCloudBook-master\eureka-server\target> java -jar eureka-server-1.0.0.jar --spring.profiles.active=peer1

// 再尝试发送几次请求，并观察启动的两个 HELLO-SERVICE 的控制台，可以看到两个控制台会交替打印下面的日志，这是我们之前在 HelloController 中实现的对服务信息的输出，
// 可以用来判断当前 ribbon-consumer 对 HELLO-SERVICE 的调用是否是负载均衡的。
// PS F:\BOOK\2022\Spring Cloud微服务实战\SpringCloudBook-master\chapter03\hello-service\target> java -jar hello-service-0.0.1-SNAPSHOT.jar --server.port=8081
// 2022-04-29 16:57:47.782  INFO 19956 --- [nio-8081-exec-1] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 16:58:38.070  INFO 19956 --- [nio-8081-exec-3] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:00:29.964  INFO 19956 --- [nio-8081-exec-5] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:01:43.699  INFO 19956 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
// 2022-04-29 17:03:58.099  INFO 19956 --- [nio-8081-exec-7] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:05:51.096  INFO 19956 --- [nio-8081-exec-9] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:05:59.440  INFO 19956 --- [nio-8081-exec-1] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:06:08.024  INFO 19956 --- [nio-8081-exec-3] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:06:08.288  INFO 19956 --- [nio-8081-exec-5] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:06:08.543  INFO 19956 --- [nio-8081-exec-7] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:06:08.776  INFO 19956 --- [nio-8081-exec-9] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:06:09.166  INFO 19956 --- [nio-8081-exec-1] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:06:09.389  INFO 19956 --- [nio-8081-exec-3] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:06:43.705  INFO 19956 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
// 2022-04-29 17:07:25.985  INFO 19956 --- [nio-8081-exec-5] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:09:34.661  INFO 19956 --- [nio-8081-exec-7] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:09:37.333  INFO 19956 --- [nio-8081-exec-8] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:10:01.184  INFO 19956 --- [nio-8081-exec-9] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:10:21.373  INFO 19956 --- [io-8081-exec-10] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service

// PS F:\BOOK\2022\Spring Cloud微服务实战\SpringCloudBook-master\chapter03\hello-service\target> java -jar hello-service-0.0.1-SNAPSHOT.jar --server.port=8082
// 2022-04-29 17:07:12.196  INFO 25000 --- [nio-8082-exec-1] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:07:32.622  INFO 25000 --- [nio-8082-exec-3] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:08:54.250  INFO 25000 --- [nio-8082-exec-5] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:09:02.705  INFO 25000 --- [nio-8082-exec-7] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:09:36.532  INFO 25000 --- [nio-8082-exec-9] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:10:00.310  INFO 25000 --- [nio-8082-exec-1] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:10:20.529  INFO 25000 --- [nio-8082-exec-3] com.didispace.web.HelloController        : /hello, host:localhost, service_id:hello-service
// 2022-04-29 17:10:42.406  INFO 25000 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration